Skip to content

Switch runtime image to Chainguard to eliminate container CVEs#88

Open
jsonmp-k8 wants to merge 3 commits intoaws:mainfrom
jsonmp-k8:reduce-container-vulnerabilities
Open

Switch runtime image to Chainguard to eliminate container CVEs#88
jsonmp-k8 wants to merge 3 commits intoaws:mainfrom
jsonmp-k8:reduce-container-vulnerabilities

Conversation

@jsonmp-k8
Copy link
Copy Markdown

@jsonmp-k8 jsonmp-k8 commented Mar 12, 2026

Summary

  • Replace eks-distro-minimal-base-glibc:latest-al23 runtime image with cgr.dev/chainguard/glibc-dynamic:latest to eliminate known CVEs in the final container image
  • Switch builder stages from amazonlinux:2023 to amazonlinux:2023-minimal to reduce builder image size (~70MB vs ~175MB)
  • Upgrade Go from 1.25.5 to 1.25.8 to pick up security patches (html/template, net/url, os)
  • Adjust shared library copy paths from /usr/lib64/ to /usr/lib/ to match Chainguard/Wolfi filesystem layout
  • Add USER 0 to override Chainguard's nonroot default (agent requires root for chroot, host filesystem access, dbus)

Motivation

The current eks-distro-minimal-base-glibc:latest-al23 runtime image inherits AL23 system-level vulnerabilities, including glibc CVEs (e.g. CVE-2026-0915 — stack content leak in getnetbyaddr, CVE-2026-0861 — heap corruption in memalign). While the image is already minimal, these CVEs are present in the base layer and cannot be mitigated without switching base images.

Chainguard's glibc-dynamic is purpose-built for this use case:

eks-distro-minimal-base-glibc chainguard/glibc-dynamic
Known CVEs Inherits AL23 glibc/system CVEs Zero or near-zero (rebuilt daily)
Shell / package manager None None
glibc included Yes Yes
Multi-arch (amd64/arm64) Yes Yes
Free to use Yes Yes (public catalog)

Compatibility

  • glibc ABI: glibc maintains strict backward ABI compatibility. The systemd and DCGM .so files copied from the AL2023 builder stages work correctly on Chainguard's newer glibc.
  • Builder stages slimmed: Both AL2023 builder stages (systemd-builder, dcgm-builder) switched from amazonlinux:2023 to amazonlinux:2023-minimal. The minimal image includes dnf, sed, and coreutils — all dependencies used during the build. These stages only extract .so files and do not affect the final image's vulnerability surface.
  • Library paths: Chainguard/Wolfi uses /usr/lib/ as the standard dynamic linker search path instead of AL23's /usr/lib64/. All COPY destinations updated accordingly.
  • Root user: Chainguard images default to nonroot (UID 65532). Added explicit USER 0 since the agent requires root for chroot operations, host filesystem access, and dbus socket communication. This matches the previous image's default behavior.
  • Go builder: No slim variant available — Alpine uses musl libc which is incompatible with CGO + libsystemd-dev (glibc). Left as-is.

Test plan

  • Build the Docker image locally: docker build -t eks-node-monitoring-agent .
  • Verify the binary starts: docker run --rm eks-node-monitoring-agent --help
  • Verify shared library resolution with LD_DEBUG=libs
  • Run e2e tests on an EKS cluster with GPU and non-GPU nodes
  • Scan the new image with a vulnerability scanner (e.g. trivy image, grype, or Amazon Inspector) and confirm reduced CVE count

The eks-distro-minimal-base-glibc:latest-al23 runtime image carries
inherited AL23 system-level CVEs (e.g. glibc CVE-2026-0915,
CVE-2026-0861). Replace it with cgr.dev/chainguard/glibc-dynamic:latest,
which is rebuilt daily from source with zero or near-zero known
vulnerabilities and contains no shell or package manager.

Also upgrades the Go builder from 1.25.5 to 1.25.8 to pick up security
fixes in html/template, net/url, and os packages.

Key changes:
- Runtime: eks-distro-minimal-base-glibc -> chainguard/glibc-dynamic
- Go: 1.25.5 -> 1.25.8 (Dockerfile + go.mod)
- Library copy paths: /usr/lib64/ -> /usr/lib/ (Wolfi filesystem layout)

Builder stages (AL2023 for systemd/DCGM .so extraction) are unchanged
since they do not contribute to the final image's vulnerability surface.
glibc maintains strong backward ABI compatibility, so libraries compiled
against AL2023's glibc work correctly on Chainguard's newer glibc.

Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
Chainguard glibc-dynamic runs as nonroot (UID 65532) by default. The
agent requires root for chroot operations, host filesystem access, and
dbus socket communication. Without this, the agent would fail at runtime
despite running in a privileged container.

Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
Switch both systemd-builder and dcgm-builder from amazonlinux:2023 to
amazonlinux:2023-minimal (~70MB vs ~175MB). The minimal image includes
dnf for package installation but ships fewer pre-installed packages,
reducing builder layer size and pull time.

The go-builder cannot use a slim variant because golang images have no
-slim tag, and the Alpine variant uses musl libc which is incompatible
with the CGO + libsystemd-dev (glibc) build requirement.

Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
@micahhausler
Copy link
Copy Markdown
Member

Thanks for this PR! We won't be able to accept/merge this as is, we have internal policies around distributing software we build from source and not 3rd party images.

If you'd still like to build this image yourself, you could parameterize some of the changes as ARGs to make self-building this easier if you want to base it on Chainguard.

Examples would look like:

+ ARG BASE_GLIBC_IMG=public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-glibc:latest-al23
- FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-glibc:latest-al23 AS runtime
+ FROM ${BASE_GLIBC_IMG} AS runtime
+ ARG LIB_DIR=/usr/lib64
- COPY --from=systemd-builder /usr/lib64/libsystemd.so* /usr/lib64/
+ COPY --from=systemd-builder /usr/lib64/libsystemd.so* ${LIB_DIR}/

so you can run

docker build --build-args BASE_GLIBC_IMG=cgr.dev/chainguard/glibc-dynamic:latest LIB_DIR=/usr/lib ...

Copy link
Copy Markdown
Contributor

@prasad0896 prasad0896 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned by Micah previously, we can't merge this PR as we can't use 3rd party images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants